local skel = fk.CreateSkill {
  name = "lb__quansheng",
}

Fk:loadTranslationTable {
  ["lb__quansheng"] = "全胜",
  --[":lb__quansheng"] = "当你造成伤害后，若目标武将牌上有「<b>垒击</b>」牌，你可以失去1点体力并获得场上所有「<b>垒击</b>」牌，然后你可以发动一次<a href=':lb__leiji'><font color='red'>〖垒击〗</font></a>。",
  --9.18
  [":lb__quansheng"] = "每回合限一次，当你造成/受到伤害后，若受伤角色/伤害来源有「<b>垒击</b>」牌，你可以获得场上所有「<b>垒击</b>」牌，然后你可以发动一次<a href=':lb__leiji'><font color='red'>〖垒击〗</font></a>。",

  ["$lb__quansheng1"] = "规则，就是用来打破的。",
  ["$lb__quansheng2"] = "致胜一击！",
}
--[[
skel:addEffect(fk.Damage, {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and #data.to:getPile("lb__leiji") > 0
        and player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    --room:loseHp(player, 1, skel.name)
    if not player.dead then
      for _, t in ipairs(room:getAlivePlayers()) do
        for _, c in ipairs(t:getPile("lb__leiji")) do
          room:obtainCard(player, c, true, fk.ReasonJustMove, player)
        end
      end
      room:askToUseActiveSkill(player, {
        skill_name = "lb__leiji",
        prompt = "#lb__leiji",
      })
    end
  end,
})
--]]

local quansheng_spec = {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    local to = data.to
    if event == fk.Damaged then
      to = data.from
    end
    return target == player and player:hasSkill(skel.name)
        and to and to:isAlive() and #to:getPile("lb__leiji") > 0
        and player:usedSkillTimes(skel.name, Player.HistoryTurn) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    --room:loseHp(player, 1, skel.name)
    if player.dead then return end
    for _, t in ipairs(room:getAlivePlayers()) do
      for _, c in ipairs(t:getPile("lb__leiji")) do
        room:obtainCard(player, c, true, fk.ReasonJustMove, player)
        if player.dead then return end
      end
    end
    room:askToUseActiveSkill(player, {
      skill_name = "lb__leiji",
      prompt = "#lb__leiji",
    })
  end,
}

skel:addEffect(fk.Damage, quansheng_spec)
skel:addEffect(fk.Damaged, quansheng_spec)

return skel